home *** CD-ROM | disk | FTP | other *** search
- #ifndef DOS_DOSASL_H
- #include <dos/dosasl.h>
- #endif
-
- #include <proto/dos.h>
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <errno.h>
-
- /************************************************************************/
-
- #include "main.h"
- #include "ProcessDir.h"
-
- /************************************************************************/
-
- struct MyAnchorPath __ALIGN(AnchorPath);
-
- int CallMatchEnd;
-
- /************************************************************************/
- /* */
- /* Read a directory, recursively, and call Function(Filename). */
- /* */
- /************************************************************************/
-
- void
- ProcessDir1 (int Directory, char *FilePattern, void (*Function) (char *))
-
- {
- char Pattern[32];
- long Error;
-
- puts ("");
-
- CurrentDir (Dirs[Directory]);
- ParsePatternNoCase (FilePattern, Pattern, sizeof (Pattern));
- AnchorPath.AnchorPath.ap_Flags = APF_DOWILD;
- AnchorPath.AnchorPath.ap_Strlen = 1024;
- AnchorPath.AnchorPath.ap_BreakBits = SIGBREAKF_CTRL_C;
-
- CallMatchEnd = TRUE;
- Error = MatchFirst ("", &AnchorPath.AnchorPath);
- while (!Error)
- {
- if (AnchorPath.AnchorPath.ap_Flags & APF_DIDDIR)
- {
- AnchorPath.AnchorPath.ap_Flags &= ~APF_DIDDIR;
- }
- else
- {
- if (AnchorPath.AnchorPath.ap_Info.fib_DirEntryType > 0)
- {
- AnchorPath.AnchorPath.ap_Flags |= APF_DODIR;
- }
- else
- {
- if (MatchPatternNoCase (Pattern, AnchorPath.AnchorPath.ap_Info.fib_FileName))
- {
- printf ("Reading %s\n", AnchorPath.AnchorPath.ap_Buf);
- Function (AnchorPath.AnchorPath.ap_Buf);
- }
- }
- }
- Error = MatchNext (&AnchorPath.AnchorPath);
- }
- MatchEnd (&AnchorPath.AnchorPath);
- CallMatchEnd = FALSE;
- if (Error != ERROR_NO_MORE_ENTRIES)
- {
- errno=Error;
- perror (Arguments.Dirs[Directory]);
- CloseAll (RETURN_ERROR);
- }
- }
-
- /************************************************************************/
- /* */
- /* Run second pass for a directory. */
- /* */
- /************************************************************************/
-
- void
- ProcessDir2 (int Directory, struct AVLTree *DirTree, void (*Function) (struct AnyNode *))
-
- {
- struct AVLNode *CurrentNode;
- struct AVLStateInfo StateInfo;
-
- puts ("");
-
- CurrentDir (Dirs[Directory]);
-
- AVL_InitTraversal (DirTree, &StateInfo);
- while ((CurrentNode = AVL_InOrder (&StateInfo)))
- {
- Function ((struct AnyNode *) CurrentNode);
- }
- }
-